/**
 * 
 */
package com.ibm.eg.cvmanager.dao.impl;

import java.util.ArrayList;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;

import com.ibm.eg.cvmanager.dao.util.HibernateUtil;
import com.ibm.eg.cvmanager.dto.Applicant;
import com.ibm.eg.cvmanager.dto.Interviewer;

import exception.TechnicalException;

/**
 * @author SAADA
 *
 */
public class InterviewerDao extends BaseDao {
	
	private static final Log log = LogFactory.getLog(InterviewerDao.class);
		
	public ArrayList<Interviewer>filterInterviewer(String name) throws TechnicalException
	{
		ArrayList<Interviewer> interviewers;
		Session session = HibernateUtil.getCurrentSession();
		log.debug("filtering Interviewers by name");
		try{
			interviewers = (ArrayList<Interviewer>) session.createCriteria(Interviewer.class)
				.add(Restrictions.like("name", name, MatchMode.ANYWHERE)).list();
			log.debug("filter successful");
			return interviewers;
		}
		catch(HibernateException ex)
		{
			log.error("filter failed", ex);
			throw new TechnicalException("filterInterviewer(String) error in InterviewerDao",ex);
		}
	}
}
